package com.kensla.urbanairshipheliumpushforandroidtutorials;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;

import com.urbanairship.push.PushManager;
import com.urbanairship.push.PushPreferences;

public class MainActivity extends Activity {

    private static final String logTag = MainActivity.class.getName();
    
    private CheckBox enablePush;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        enablePush = (CheckBox) this.findViewById(R.id.enable_push);
        enablePush.setEnabled(true);
        enablePush.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                if (enablePush.isChecked()) {
                    PushManager.enablePush();
                    PushPreferences pref = PushManager.shared().getPreferences();
                    Log.i(logTag, "APID: " + pref.getPushId());
                } else {
                    PushManager.disablePush();
                }
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
}